﻿<!DOCTYPE html>
<html>
<head>
    <title>应用WEB报表客户端实现打印与数据导出 - 锐浪HTML5报表</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <script src="../grhtml5-6.6-min.js" type="text/javascript"></script>
    <script src="../../webapp/grwebapp.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
        function window_onload() {
            //创建报表显示器，参数指定其在网页中的占位标签的ID，关联的报表模板URL，关联的报表数据URL
            var reportViewer = rubylong.grhtml5.insertReportViewer("report_holder", "../../grf/1a.grf", "../../data/DataCenter.jsp?data=Customer");
            reportViewer.start(); //启动报表运行，生成报表

            window.rootURL = window.location.protocol + "//" + window.location.host + '/';
            
            //*这句特别重要*：只有在WEB报表客户端程序后，才能进行WebSocket通讯
            webapp_urlprotocol_startup(); //启动WEB报表客户端程序，以便侦听接受 WebSocket 数据
        }

        //应用URL协议启动WEB报表客户端程序，根据参数 args 调用对应的功能
        function webapp(args) {
            //按 webapp_urlprotocol_run 方式调用WEB报表客户端
            //args.baseurl = window.rootURL;
            //args.report = "grf/1a.grf";
            //args.data = "data/DataCenter.jsp?data=Customer&name";
            //webapp_urlprotocol_run(args);
            
            //按 webapp_ws_ajax_run 方式调用WEB报表客户端
            args.report = "/grf/1a.grf";
            args.data = "/data/DataCenter.jsp?data=Customer&name";
            webapp_ws_ajax_run(args);
        }
    </script>
    <style type="text/css">
        #toolbar span {
            margin-left:12px;
        }
        .rdock {
            position:absolute;
            right:8px;
        }
    </style>
</head>
<body onload="window_onload()">
    <div id="toolbar">
        <a href='javascript:webapp({});'>打印预览</a><span></span>
        <a href='javascript:webapp({"type":"print"});'>打印</a><span></span>
        <a href='javascript:webapp({"type":"print","showOptionDlg":"false"});'>直接打印</a><span></span>
        <a href='javascript:webapp({"type":"pdf"});'>导出PDF</a><span></span>
        <a href='javascript:webapp({"type":"xls"});'>导出Excel</a><span></span>
        <a href='javascript:webapp({"type":"rtf"});'>导出RTF</a><span></span>
        <a href='javascript:webapp({"type":"csv"});'>导出CSV</a><span></span>
        <a href='javascript:webapp({"type":"txt"});'>导出文本</a><span></span>
        <a href='javascript:webapp({"type":"img"});'>导出图像</a><span></span>
        <a href='javascript:webapp({"type":"grd"});'>生成报表文档</a>
        <a class="rdock" href="webapp-about.htm" target="_blank">执行任务无响应帮助</a>
    </div>

    <div id="report_holder">
        HTML5报表占位标签
    </div>
</body>
</html>